namespace Microsoft.ServiceModel.Samples.Discovery.Protocol
{
    using System;
    using System.Xml;
    using System.Xml.Serialization;
    using System.ServiceModel;
    
    [ServiceContract(Namespace=ProtocolStrings.Namespace)]
    [XmlSerializerFormat]
    public interface IAnnouncementContract
    {
        [OperationContract(IsOneWay = true, Action = ProtocolStrings.HelloAction)]
        void HelloOperation(HelloMessage message);

        [OperationContract(IsOneWay = true, Action = ProtocolStrings.ByeAction)]
        void ByeOperation(ByeMessage message);
    }

    [MessageContract(IsWrapped=false)]
    public class HelloMessage
    {
        AppSequence appSequence;
        Hello hello;

        public HelloMessage()
            : this(null, null)
        {
        }

        public HelloMessage(AppSequence appSequence, Hello hello)
        {
            this.appSequence = appSequence;
            this.hello = hello;
        }

        [MessageHeader(Name = ProtocolStrings.AppSequenceElement,
            Namespace = ProtocolStrings.Namespace)]
        public AppSequence AppSequence
        {
            get
            {
                return this.appSequence;
            }

            set
            {
                this.appSequence = value;
            }
        }

        [MessageBodyMember(Name = ProtocolStrings.HelloElement,
            Namespace = ProtocolStrings.Namespace)]
        public Hello Hello
        {
            get
            {
                return this.hello;
            }

            set
            {
                this.hello = value;
            }
        }
    }

    [MessageContract(IsWrapped=false)]
    public class ByeMessage
    {
        AppSequence appSequence;
        Bye bye;

        public ByeMessage()
            : this(null, null)
        {
        }

        public ByeMessage(AppSequence appSequence, Bye bye)
        {
            this.appSequence = appSequence;
            this.bye = bye;
        }

        [MessageHeader(Name = ProtocolStrings.AppSequenceElement,
            Namespace = ProtocolStrings.Namespace)]
        public AppSequence AppSequence
        {
            get
            {
                return this.appSequence;
            }

            set
            {
                this.appSequence = value;
            }
        }

        [MessageBodyMember(Name = ProtocolStrings.ByeElement,
             Namespace = ProtocolStrings.Namespace)]
        public Bye Bye
        {
            get
            {
                return this.bye;
            }

            set
            {
                this.bye = value;
            }
        }
    }
}
